<template>
  <div class="app-container">
    <!-- 上部分表单 -->
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="68px"
      class="globalSerchFormStyle"
    >
      <el-row>
        <el-col :span="6">
          <el-form-item label="客户姓名" prop="consumer">
            <el-input
              size="small"
              v-model="queryParams.likeConsumer"
              placeholder="请输入客户姓名"
              clearable
              style="width: 190px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="创建时间" prop="createdDate">
            <el-date-picker
              style="width: 190px"
              size="small"
              v-model="dateRangeCreatedDate"
              value-format="yyyy-MM-dd HH:mm:ss"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-row class="global_el_rowStyle" :gutter="10">
      <el-col :span="1.5">
        <el-button
          size="mini"
          type="primary"
          icon="el-icon-search"
          @click="handleQuery"
          >搜索</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" type="primary" icon="el-icon-plus" plain
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5"><el-button size="mini" plain>导出</el-button></el-col>
      <el-col :span="1.5"><el-button size="mini" plain>打印</el-button></el-col>
    </el-row>

    <!-- 表格 -->
    <el-table :data="orderList" style="width: 100%" stripe>
      <af-table-column
        label="油站名"
        align="left"
        fixed
        prop="stationName"
        v-if="jiBie == 0 || jiBie == 1"
        sortable
      />
      <af-table-column
        label="应付金额（元）"
        align="left"
        prop="receivableAmt"
        sortable
      />
      <af-table-column
        label="实付金额（元）"
        align="left"
        prop="amt"
        sortable
      />
      <af-table-column label="客户姓名" align="left" prop="consumer" sortable />
      <af-table-column
        label="加油员"
        align="left"
        prop="oilPersonnel"
        sortable
      />

      <af-table-column
        label="支付类型"
        align="left"
        prop="payType"
        :formatter="payTypeFotmat"
        sortable
      />
      <af-table-column
        v-if="false"
        label="油站id"
        align="left"
        prop="stationId"
        sortable
      />
      <af-table-column
        label="状态"
        align="left"
        prop="status"
        width="120"
        :formatter="statusFotmat"
        sortable
      />
      <af-table-column label="支付时间" align="left" prop="payDate" sortable>
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.payDate, "{y}-{m}-{d} {h}:{i}:{s}")
          }}</span>
        </template>
      </af-table-column>
      <af-table-column
        label="创建时间"
        align="left"
        prop="createdDate"
        sortable
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.createdDate, "{y}-{m}-{d} {h}:{i}:{s}")
          }}</span>
        </template>
      </af-table-column>
      <af-table-column label="订单号" align="left" prop="orderNo" sortable />

      <!-- 复制 -->
      <af-table-column label="支付时间" align="left" prop="payDate" sortable>
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.payDate, "{y}-{m}-{d} {h}:{i}:{s}")
          }}</span>
        </template>
      </af-table-column>
      <af-table-column
        label="创建时间"
        align="left"
        prop="createdDate"
        sortable
      >
        <template slot-scope="scope">
          <span>{{
            parseTime(scope.row.createdDate, "{y}-{m}-{d} {h}:{i}:{s}")
          }}</span>
        </template>
      </af-table-column>
      <af-table-column label="订单号" align="left" prop="orderNo" sortable />
      <!-- 复制 -->

      <af-table-column fixed="right" label="操作" align="left" width="150">
        <template>
          <el-button type="success" size="small">查看</el-button>
          <el-button type="danger" size="small">编辑</el-button>
        </template>
      </af-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<script>
import { listOrder, exportOrder } from "@/api/station/noorder";
export default {
  name: "Order_NotOil",
  data() {
    return {
      //创建订单时间间隔
      dateRangeCreatedDate: [],
      // 总条数
      total: 0,
      // 订单支付表格数据
      orderList: [],
      //字典
      payTypeOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        stationId: this.deptId,
        createdDate: null,
        orderType: 2,
        likeConsumer: null,
        levelId: this.levelId,
      },
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
    //字典
    this.getDicts("pay_type").then((response) => {
      this.payTypeOptions = response.data;
    });
  },
  methods: {
    payTypeFotmat(row, column) {
      if (row.payType === "wx") {
        return "微信支付";
      } else if (row.payType === "zfb") {
        return "支付宝支付";
      } else if (row.payType === "xj") {
        return "现金支付";
      } else if (row.payType === "dzk") {
        return "电子卡支付";
      } else if (row.payType === "POS") {
        return "POS机支付";
      } else if (row.payType === "yzf") {
        return "预支付";
      } else if (row.payType === "kbzf") {
        return "卡包支付";
      }
    },
    statusFotmat(row, column) {
      if (row.status === "0") {
        return "未支付";
      } else if (row.status === "1") {
        return "已支付";
      } else if (row.status === "2") {
        return "线下退款";
      } else if (row.status === "3") {
        return "线上退款";
      }
    },
    /** 查询订单支付列表 */
    getList() {
      this.queryParams.levelId = this.levelId;
      listOrder(
        this.addDateRange(this.queryParams, this.dateRangeCreatedDate)
      ).then((response) => {
        this.orderList = response.rows;
        this.total = response.total;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreatedDate = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有订单支付数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return exportOrder(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
        });
    },
  },
};
</script>
<style lang="scss" scoped>
.app-container {
  margin-top: -15px;
}
// 按钮适配样式
.button-from {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  .button-style1 {
    display: inline-block;
    width: 80px;
    margin-center: 8px;
  }
}
::v-deep .card-table {
  margin-top: 40px;
  background-color: #f8f8f8;
  // 操作按钮样式
  .el-button {
    margin-bottom: 0px;
    margin-right: 0px;
  }
}

// 表格样式
// ::v-deep .el-form-item {
//   margin-bottom: 0;
//   .el-form-item__label {
//     padding: 0;
//     margin: 0;
//     height: 29px;
//     font-weight: 400;
//     font-size: 12px;
//   }
//   .el-button--cyan {
//     margin-center: 20px;
//   }
// }
::v-deep .el-table {
  border: 1px #f8f8f8 solid;
  border-bottom: 1px #dfe6ec solid;
}
::v-deep .is-center {
  border: 1px transparent solid;
  border-bottom: 1px #f8f8f8 solid;
}
</style>
